using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMinionController:MonoBehaviour {

	public GameObject toFollow;
	public float teleportDistance = 10;
	Mob mob;

	void Start() {
		mob=GetComponent<Mob>();
		if(!toFollow) toFollow=Player.instance.gameObject;
		transform.parent=toFollow.transform.parent;
	}

	void FixedUpdate() {
		if((transform.position-toFollow.transform.position).sqrMagnitude>teleportDistance*teleportDistance)
			TeleportToOwner();
		mob.wanderCenter=toFollow.transform.position;
	}

	void TeleportToOwner() {
		transform.position=toFollow.transform.position;

	}
}
